﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using SharpCompress.Writer.Zip;

namespace ComicsEditor
{
    public class WriterPackage : IComicWriter
    {
        public readonly string PackageName;

        private FileStream fileStream;
        private ZipWriter writer;

        public WriterPackage(string PackageName)
        {
            this.PackageName = PackageName;
            fileStream = File.Open(PackageName, FileMode.Create, FileAccess.Write, FileShare.Read);
            writer = new ZipWriter(fileStream, SharpCompress.Common.Zip.CompressionMethod.Deflate, null);
        }

        public void AddStream(string key, Stream stream)
        {
            writer.Write(key, stream, null, null);
        }

        public void Close()
        {
            writer.Dispose();
            fileStream.Close();
        }
    }
}
